﻿'========================================================================
'功能:庫別設定虛擬倉設定,存檔時會將資產的虛擬倉做修改
'作者:andy
'日期: 2011/5/26
'========================================================================
Imports System.Data
Partial Class WebForm_StoreHouseMaintain
    Inherits BasePage
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            hiUID.Value = ActualUID
            hiDBName.Value = dbName
            If ChkProgramRight("1") = False Then '查詢
                gvStoreHouse.Visible = False
                btnQuery.Visible = False
            End If
            If ChkProgramRight("2") = False Then '新增
                btnInsert.Visible = False
                plInsert.Visible = False
            End If
            If ChkProgramRight("3") = False Then '修改
                gvStoreHouse.Columns(0).Visible = False

            End If
            If ChkProgramRight("4") = False Then '刪除
                gvStoreHouse.Columns(1).Visible = False

            End If
        End If

    End Sub






    Protected Sub btnQuery_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnQuery.Click
        gvStoreHouse.DataBind()
    End Sub

    Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Dim stBBl As AssetManage.BBL.StoreHouseBBL = New AssetManage.BBL.StoreHouseBBL()
        If stBBl.StoreHouseIsExist(txtHouse_IDIns.Text, hiDBName.Value) Then
            ShowMessageForAjax(btnSave, GetLocalResourceObject("HoueIDExist"))
            mpIns.Show()
            Exit Sub
        End If

        stBBl.InsertStoreHouse(txtHouse_IDIns.Text, txtNameIns.Text, txtDescIns.Text, hiUID.Value, hiDBName.Value)
        gvStoreHouse.DataBind()

    End Sub


    Protected Sub gvStoreHouse_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles gvStoreHouse.RowDeleting
        Dim assDao As AssetManage.DAO.AssetDAO = New AssetManage.DAO.AssetDAO(hiDBName.Value)

        If assDao.StoreHouseIsExist(e.Keys(0)) Then
            e.Cancel = True
            ShowMessageForAjax(btnCancel, "Store House is used in Asset Manage System")
        End If
    End Sub
End Class
